DEV Community

Alex Reis
Alex Reis

Posted on

1 1 1 1 1

Git: Commands beginners don't know

Git is a Version Control System designed to handle everything from small to very large projects with speed and efficiency. You should already the basics commands: init, add, commit and push. But I want to introduce you to some basic commands that can help you a lot, so let's go.

git merge

Incorporates changes from the commits of another branch into the current branch.

$ git checkout <branch that will receive changes>
$ git merge <branch with changes>
Enter fullscreen mode Exit fullscreen mode

git rebase

Reapply commits on top of another branch.

$ gut checkout <branch that will receive changes>
$ git rebase <branch with changes>
Enter fullscreen mode Exit fullscreen mode

git stash

Use git stash when you want to record the current state of the working directory and the index, but not commit this modifications.

$ git stash
Enter fullscreen mode Exit fullscreen mode

Can be list the modifications stashes:

$ git stash list
Enter fullscreen mode Exit fullscreen mode

Restored:

$ git stash apply
Enter fullscreen mode Exit fullscreen mode

Apply specific stash:

$ git stash apply stash@{2}
Enter fullscreen mode Exit fullscreen mode

git cherry pick

Apply the changes introduced by some existing commits.

$ git cherry-pick <commit hash>
Enter fullscreen mode Exit fullscreen mode

git commit --amend

Modify the latest commit:

$ git commit --amend
Enter fullscreen mode Exit fullscreen mode

If you commit and forgot to stage the changes in a file you wanted to add to this commit:

$ git commit -m 'Initial commit'
$ git add forgotten_file
$ git commit --amend
Enter fullscreen mode Exit fullscreen mode

Conclusion

Eu hope this article has been helpful for your learning. Look the 'Reference' to learn more about git.

Reference

Git Documentation

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay