Question: In short, the repository is old and huge, say 7GB. For instance, the current branch is `branch01` and the remote is called `origin`. The task is to create a new empty commit on `branch02`. Basically, the empty commit is to trigger the CI(Continuous integration) process when doing the git-push.

However, switching from one branch to another branch might take seconds, or even minutes since there might be a lot of IO operation. Is there a way to create the empty commit on the `branch02` without switching to it, just like below.

```
# to create the empty commit
# git command: hash-object, write-tree, commit-tree

# after the empty commit is created
git push origin branch02:branch02

```

Answer: 
Just to answer the original question, you can do that with a few low-level commands:

```
cmt=$(git commit-tree -m "trigger Jenkins" -p branch02 branch02^{tree}) &&
git update-ref refs/heads/branch02 $cmt

```

That is, you create a new commit object with the same tree object as the original branch and the original branch as parent, and then you point the branch to the new commit.
Yes, you can. But note the below steps for creating commits on that branch.

1. `git symbolic-ref HEAD refs/heads/otherbranch` Will checkout without updating the files.
2. Reset your index as per the new branch by `git reset` If you don't do this, you end up committing something based on last checked-out branch
3. Stage file(s) you want to commit using `git add <filename>`
4. Create commit(s)
5. **Before switching back** add all the files which got un-staged in step 2. Use `git add .`
6. Checkout to old branch `git checkout old_branch`
7. Lastly, reset your index again with `git reset` You need this step because the files which were untracked in the beginning will get staged as deleted during checkout. Reset will change the status of those files back to untracked.